﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Abp.Domain.Services;
using AVISOutBound.SSOServer.Payment.Alipay;
using Microsoft.AspNetCore.Http;

namespace AVISOutBound.SSOServer.Payment
{
    /// <summary>
    /// 支付宝的领域服务
    /// </summary>
    public interface IAlipayManager:IDomainService
    {
        /// <summary>
        /// 二维码支付
        /// </summary>
        /// <param name="subject">订单标题</param>
        /// <param name="body">订单描述</param>
        /// <param name="orderAmount">订单金额。单位：元</param>
        /// <param name="outTradeNo">外部订单号，商户网站订单系统中唯一的订单号</param>
        /// <param name="notifyUrl">支付完成异步通知接收地址</param>
        /// <returns></returns>
        string QrCodePay(string subject, string body, string orderAmount, string outTradeNo, string notifyUrl);

        /// <summary>
        /// 手机网站支付
        /// </summary>
        /// <param name="subject">订单标题</param>
        /// <param name="body">订单描述</param>
        /// <param name="orderAmount">订单金额。单位：元</param>
        /// <param name="outTradeNo">外部订单号，商户网站订单系统中唯一的订单号</param>
        /// <param name="returnUrl">支付完成后同步回调地址</param>
        /// <param name="notifyUrl">支付完成异步通知接收地址</param>
        /// <param name="timeoutExpress">该笔订单允许的最晚付款时间，逾期将关闭交易。取值范围：1m～15d。m-分钟，h-小时，d-天，1c-当天（1c-当天的情况下，无论交易何时创建，都在0点关闭）。 该参数数值不接受小数点， 如 1.5h，可转换为 90m</param>
        /// <returns></returns>
        Task<string> WapPay(string subject, string body, string orderAmount, string outTradeNo, string returnUrl,
            string notifyUrl, string timeoutExpress = "5m");

        /// <summary>
        /// PC网站支付
        /// </summary>
        /// <param name="subject">订单标题</param>
        /// <param name="body">订单描述</param>
        /// <param name="orderAmount">订单金额。单位：元</param>
        /// <param name="outTradeNo">外部订单号，商户网站订单系统中唯一的订单号</param>
        /// <param name="returnUrl">支付完成后同步回调地址</param>
        /// <param name="notifyUrl">支付完成异步通知接收地址</param>
        /// <param name="timeoutExpress">该笔订单允许的最晚付款时间，逾期将关闭交易。取值范围：1m～15d。m-分钟，h-小时，d-天，1c-当天（1c-当天的情况下，无论交易何时创建，都在0点关闭）。 该参数数值不接受小数点， 如 1.5h，可转换为 90m</param>
        /// <returns></returns>
        Task<string> PcPay(string subject, string body, string orderAmount, string outTradeNo, string returnUrl,
            string notifyUrl, string timeoutExpress = "5m");

        /// <summary>
        /// 处理支付宝支付回调内容
        /// </summary>
        /// <param name="context">Http上下文</param>
        /// <returns></returns>
        AlipayPayReceive ParseNotify(HttpContext context);

        /// <summary>
        /// 支付退款
        /// </summary>
        /// <param name="tradeno">商户订单号</param>
        /// <param name="alipayTradeNo">支付宝交易号</param>
        /// <param name="refundAmount">退款金额。单位：元</param>
        /// <param name="refundReason">退款原因</param>
        /// <param name="refundNo">退款单号</param>
        AlipayRefundResult Refund(string tradeno, string alipayTradeNo, string refundAmount, string refundReason,
            string refundNo);
    }
}
